package com.powernode.driver.config;

import cn.binarywang.wx.miniapp.api.WxMaService;
import cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl;
import cn.binarywang.wx.miniapp.config.impl.WxMaDefaultConfigImpl;

import com.powernode.driver.properties.WxMaProperties;
import jakarta.annotation.Resource;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

/**
 *  Binary Wang/WxJava 配置类
 */
@Component
public class WxMaConfig {

    @Resource
    private WxMaProperties properties;

    @Bean
    public WxMaService wxMaService(){
        //将我们的appid和secret设置到WxMaDefaultConfigImpl中
        WxMaDefaultConfigImpl config = new WxMaDefaultConfigImpl();
        config.setAppid(properties.getAppId());
        config.setSecret(properties.getSecret());

        //将配置传入service
        WxMaService wxMaService = new WxMaServiceImpl();
        wxMaService.setWxMaConfig(config);


        return wxMaService;
    }

}
